import {
  LocalizationContext,
  MinimalButton,
  Position,
  Tooltip,
} from "../../core";

import { RenderDownloadProps } from "./Download";
import DownloadIcon from "./DownloadIcon";
import { FC, useContext } from "react";

const TOOLTIP_OFFSET = { left: 0, top: 8 };

const DownloadButton: FC<RenderDownloadProps> = ({ onClick }) => {
  const l10n = useContext(LocalizationContext);

  const label = l10n && l10n.download ? l10n.download.download : "Download";

  return (
    <Tooltip
      position={Position.BottomCenter}
      target={
        <MinimalButton onClick={onClick}>
          <DownloadIcon />
        </MinimalButton>
      }
      content={() => label}
      offset={TOOLTIP_OFFSET}
    />
  );
};

export default DownloadButton;
